package com.briup.gsauestore.dao;

import com.briup.gsauestore.bean.ShopCar;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author adam
 * @date  2022/1/12
 */
@Repository
public interface IShopCarDao extends JpaRepository<ShopCar, Long> {

    ShopCar findByUserIdAndShopId(long userId,long shopId);

    List<ShopCar>  findByUserId(long userId);


    @Query(nativeQuery = true,value = "update t_shop_car set num=?1 where id=?2")
    @Modifying
    @Transactional
    void  updateNumById(int num,long id);

}
